package com.cluster.platform.controller;

import com.cluster.platform.common.api.CommonResult;
import com.cluster.platform.model.PmsSecondProduct;
import com.cluster.platform.service.PmsSecondProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: PmsSecondProductController
 * @Author: admin
 * @Date: 2021/2/19 16:34
 * @修改日志
 */
@RestController
@Api(tags = "闲置商品接口", value = "PmsSecondProductController")
@RequestMapping("/pmsSecondProduct")
public class PmsSecondProductController {

    @Autowired
    PmsSecondProductService pmsSecondProductService;

    @ApiOperation("新增闲置")
    @PostMapping("/addPmsSecondProduct")
    public CommonResult<Object> addPmsSecondProduct(@RequestBody PmsSecondProduct pmsSecondProduct) {
        return pmsSecondProductService.addPmsSecondProduct(pmsSecondProduct);
    }

    @ApiOperation("删除闲置 逻辑")
    @DeleteMapping("/delPmsSecondProduct")
    public CommonResult<Object> delPmsSecondProduct(@RequestParam("id") String id, @RequestParam("username") String username) {
        return pmsSecondProductService.delPmsSecondProduct(id, username);
    }

    @ApiOperation("删除闲置 物理")
    @DeleteMapping("/deletePmsSecondProduct")
    public CommonResult<Object> deletePmsSecondProduct(@RequestParam("id") String id) {
        return pmsSecondProductService.deletePmsSecondProduct(id);
    }

    @ApiOperation("更新闲置")
    @PutMapping("/updatePmsSecondProduct")
    public CommonResult<Object> updatePmsSecondProduct(@RequestBody PmsSecondProduct pmsSecondProduct) {
        return pmsSecondProductService.updatePmsSecondProduct(pmsSecondProduct);
    }

    @ApiOperation("分页查询所有")
    @GetMapping("/searchPmsSecondProductAll")
    public CommonResult<Object> searchPmsSecondProductAll(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) {
        return pmsSecondProductService.searchPmsSecondProductByLimit(pageSize, pageNum);
    }

    @ApiOperation("分页查询可用数据")
    @GetMapping("/searchPmsSecondProductByStatus")
    public CommonResult<Object> searchPmsSecondProductByStatus(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) {
        return pmsSecondProductService.searchPmsSecondProductByStatus(pageSize, pageNum);
    }

    @ApiOperation("根据商品名称分页查询信息")
    @GetMapping("/searchPmsSecondProductByName")
    public CommonResult<Object> searchPmsSecondProductByName(@RequestParam("name") String name, @RequestParam("status") Integer status, @RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) {
        return pmsSecondProductService.searchPmsSecondProductByName(name, status, pageSize, pageNum);
    }


}
